#define DEBUG
#include <cstdio>
#define MAXN 1000000

using namespace std;

long long sqr(long long a) {
  return a*a;
}

long double getPoint(long long *a, long long *b) {
  return (long double)(a[1]-b[1])/(b[0]-a[0]);
}

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  static int x[MAXN+1];
  static long long s[MAXN+1];
  int n;
  long long a, b, c;
  scanf("%d %lld %lld %lld", &n, &a, &b, &c);
  for (int i=1; i<=n; i++) {
    scanf("%d", x+i);
    s[i]=s[i-1]+x[i];
  }

  static long long que[MAXN+2][2];
  int h=1, t=1;
  long long temp[2], f;
  que[0][0]=0, que[0][1]=0;
  for (int i=1; i<=n; i++) {
    for (; h<t && getPoint(que[h], que[h+1])<s[i]; h++);
    f=a*sqr(s[i])+b*s[i]+c+que[h][0]*s[i]+que[h][1];
    temp[0]=-2LL*a*s[i], temp[1]=a*sqr(s[i])-b*s[i]+f;
    for (; h<t && ((temp[0]==que[t][0] && temp[1]>que[t][1]) || (temp[0]!=que[t][0] && getPoint(que[t-1], que[t])>=getPoint(que[t-1], temp))); t--);
    if (temp[0]!=que[t][0] || temp[1]!=que[t][1]) {
      t++;
      que[t][0]=temp[0], que[t][1]=temp[1];
    }
  }
  printf("%lld", f);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
